//
//  HZProductTextImageDetailHeadView.m
//  app
//
//  Created by 刘华舟 on 15/6/4.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZProductTextImageDetailHeadView.h"

static const NSUInteger kMainViewHeight = 80;

@interface HZProductTextImageDetailHeadView()

@property (strong, nonatomic) UILabel *leftLabel;
@property (strong, nonatomic) UILabel *centerLabel;
@property (strong, nonatomic) UILabel *rightLabel;

@end

@implementation HZProductTextImageDetailHeadView

- (void)drawRect:(CGRect)rect{
    [self drawSeperatorLineLeft:[self.ubo uw:0] right:[self.ubo uw:0]];
    [self drawVerticalLineTop:[self.ubo uw:kSizeMallViewMargin] bottom:[self.ubo uw:kSizeMallViewMargin] at:[self.ubo fw:UB_1_3]];
    [self drawVerticalLineTop:[self.ubo uw:kSizeMallViewMargin] bottom:[self.ubo uw:kSizeMallViewMargin] at:[self.ubo fw:UB_2_3]];
}

- (instancetype)initWithFrame:(CGRect)frame{
    frame = CGRectOf([UBO_SCREEN fx:0 fy:0], [UBO_SCREEN fw:UB_WIDTH uh:kMainViewHeight]);
    if(self = [super initWithFrame:frame]){
        self.backgroundColor = HZ_WHITE_COLOR;
        //官方正品
        self.leftLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT fy:UB_TOP],
                                                                 [self.ubo fw:UB_1_3 fh:UB_HEIGHT])];
        self.leftLabel.textAlignment = NSTextAlignmentCenter;
        self.leftLabel.backgroundColor = HZ_CLEAR_COLOR;

        NSTextAttachment * textAttachment = [[NSTextAttachment alloc] init];//添加附件,图片
        
        UIImage *image = [UIImage imageNamed:kImageDeliveryGuan];
        
        textAttachment.image = image;
        
        textAttachment.bounds = CGRectMake(0, -3, image.size.width , image.size.height);
        
        NSAttributedString *imgString = [NSMutableAttributedString attributedStringWithAttachment:textAttachment];
        NSMutableAttributedString *atrString = [[NSMutableAttributedString alloc] initWithString:@" 官方正品"];
        [atrString addAttribute:NSForegroundColorAttributeName value:HZ_MALL_TEXT_L_LIGHTGRAY_COLOR range:NSMakeRange(0, @" 官方正品".length)];
        [atrString addAttribute:NSFontAttributeName value:JKAppGlobleFontMinTagText range:NSMakeRange(0, @" 官方正品".length)];
        [atrString insertAttributedString:imgString atIndex:0];
        
        self.leftLabel.attributedText = atrString;
        
        [self addSubview:self.leftLabel];
        
        //24h闪电发货
        self.centerLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_1_3 fy:UB_TOP],
                                                                 [self.ubo fw:UB_1_3 fh:UB_HEIGHT])];
        self.centerLabel.textAlignment = NSTextAlignmentCenter;
        self.centerLabel.backgroundColor = HZ_CLEAR_COLOR;
        
        NSTextAttachment * textCenterAttachment = [[NSTextAttachment alloc] init];//添加附件,图片
        
        UIImage *imageCenter = [UIImage imageNamed:kImageDeliveryShan];
        
        textCenterAttachment.image = imageCenter;
        
        textCenterAttachment.bounds = CGRectMake(0, -3, imageCenter.size.width , imageCenter.size.height);
        
        NSAttributedString *imgStringCenter = [NSMutableAttributedString attributedStringWithAttachment:textCenterAttachment];
        NSMutableAttributedString *atrStringCenter = [[NSMutableAttributedString alloc] initWithString:@" 24h闪电发货"];
        [atrStringCenter addAttribute:NSForegroundColorAttributeName value:HZ_MALL_TEXT_L_LIGHTGRAY_COLOR range:NSMakeRange(0, @" 24h闪电发货".length)];
        [atrStringCenter addAttribute:NSFontAttributeName value:JKAppGlobleFontMinTagText range:NSMakeRange(0, @" 24h闪电发货".length)];
        [atrStringCenter insertAttributedString:imgStringCenter atIndex:0];
        
        self.centerLabel.attributedText = atrStringCenter;
        
        [self addSubview:self.centerLabel];
        
        //15填无忧退换
        self.rightLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_2_3 fy:UB_TOP],
                                                                 [self.ubo fw:UB_1_3 fh:UB_HEIGHT])];
        self.rightLabel.textAlignment = NSTextAlignmentCenter;
        self.rightLabel.backgroundColor = HZ_CLEAR_COLOR;
        
        NSTextAttachment * textAttachmentRight = [[NSTextAttachment alloc] init];//添加附件,图片
        
        UIImage *imageRight = [UIImage imageNamed:kImageDeliveryBackGoods];
        
        textAttachmentRight.image = imageRight;
        
        textAttachmentRight.bounds = CGRectMake(0, -3, imageRight.size.width , imageRight.size.height);
        
        NSAttributedString *imgStringRight = [NSMutableAttributedString attributedStringWithAttachment:textAttachmentRight];
        NSMutableAttributedString *atrStringRight = [[NSMutableAttributedString alloc] initWithString:@" 15天无忧退换"];
        [atrStringRight addAttribute:NSForegroundColorAttributeName value:HZ_MALL_TEXT_L_LIGHTGRAY_COLOR range:NSMakeRange(0, @" 15天无忧退换".length)];
        [atrStringRight addAttribute:NSFontAttributeName value:JKAppGlobleFontMinTagText range:NSMakeRange(0, @" 15天无忧退换".length)];
        [atrStringRight insertAttributedString:imgStringRight atIndex:0];
        
        self.rightLabel.attributedText = atrStringRight;
        
        [self addSubview:self.rightLabel];
        
    }
    
    return self;
}
@end
